using System;
using System.Collections.Generic;
using System.Text;
using Dracham.TileManagement;

namespace Dracham.Classes
{
    public class Position
    {
        private Int32 mapX = default(Int32);
        private Int32 mapY = default(Int32);
        private Int32 tileX = default(Int32);
        private Int32 tileY = default(Int32);
        private Zone zone = null;

        #region properties

        public Int32 MapX
        {
            get { return this.mapX; }
            set { if(!zone.IsCollision(value, this.mapY)) this.mapX = value; }
        }

        public Int32 MapY
        {
            get { return this.mapY; }
            set { if (!zone.IsCollision(this.mapX, value)) this.mapY = value; }
        }
        public Zone Zone
        {
            get { return this.zone; }
            set { this.zone = value; }
        }

        public Int32 TileX
        {
            get { return this.tileX; }
            set { this.tileX = value; }
        }

        public Int32 TileY
        {
            get { return this.tileY; }
            set { this.tileY = value; }
        }
       
        #endregion

        public Position(Int32 mapX, Int32 mapY, String zoneId) : this(mapX, mapY, ZoneFactory.GetZoneById(zoneId)) { }
        public Position(Int32 mapX, Int32 mapY, Zone zone)
        {
            this.mapX = mapX;
            this.mapY = mapY;
            this.Zone = zone;

            this.tileX = 0;
            this.tileY = 0;
        }
    }
}
